<?php
/**
 * Created by PhpStorm.
 * User: waw
 * Date: 2019/6/12
 * Time: 17:09
 */
header("Content-type:application/json;charset=utf-8");
if ($_SERVER["REQUEST_METHOD"]=="GET"){
    $result=array("msg"=>"对不起不支持Get请求","status"=>-1);
    print_r(json_encode($result));
    return;
}
//post请求
$uname=$_POST["uname"];
$upwd=$_POST["upwd"];
//创建数据库连接
$conn=new mysqli("localhost","root","","yemaijiu","3306");
//设置连接字符集
mysqli_query($conn,"set names utf8");
//准备sql语句
$sql="SELECT `u_name`,`u_pwd`FROM registor WHERE u_name='".$uname."' AND u_pwd='".$upwd."'";
//执行sql语句
$dataResult=$conn->query($sql);
if($dataResult->num_rows>=1){

    $data=$dataResult->fetch_assoc();
    session_start();
    $_SESSION["registor"]=$data;
    $result=array("msg"=>"登录成功","status"=>1,"data"=>$data);
    print_r(json_encode($result));
}else{
    $result=array("msg"=>"登录失败","status"=>-4);
    print_r(json_encode($result));
}
$conn->close();
